< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03020102.xhp

(section: freefile) (bookmark: bm_id3150400)
FreeFile function

FreeFile 関数

FreeFile Function[Runtime]
FreeFile 関数 [実行時](hd_id3150400.1)

Returns the next available file number for opening a file. Use this function to open a file using a file number that is not already in use by a currently open file.
ファイルのオープン用に、現在使用可能な次のファイル番号を返します。この関数は、現在オープン中のファイルが使用していないファイル番号を取得する際に使用します。(par_id3154366.2)

(/section: freefile)

Syntax:
構文:(hd_id3150769.3)

FreeFile
FreeFile(par_id3150869.4)

Return value:
戻り値:(hd_id3151042.5)

Integer
整数(par_id3150440.6)

Parameters:
パラメータ:(hd_id3148576.7)

This function can only be used immediately in front of an Open statement. FreeFile returns the next available file number, but does not reserve it.
この関数を使用できるのは、Open ステートメントの直前だけです。FreeFile 関数は、利用可能な次のファイル番号を返しますが、この番号を予約するわけではありません。(par_id3155854.8)

(embed text/sbasic/shared/00000003.xhp#errorcode : linkinfo)

Error Codes

エラーコード(hd_id3152869.37)

(/embed text/sbasic/shared/00000003.xhp#errorcode)

(embed text/sbasic/shared/00000003.xhp#err5 : linkinfo)

5 Invalid procedure call
5 無効なプロシージャー呼び出しです (par_id3150891.41)

(/embed text/sbasic/shared/00000003.xhp#err5)

(embed text/sbasic/shared/00000003.xhp#err67 : linkinfo)

67 Too many files
67 ファイル数が多すぎます (par_id3146883.68)

(/embed text/sbasic/shared/00000003.xhp#err67)

Example:
例:(hd_id3159153.9)

Sub ExampleWorkWithAFile
Sub ExampleWorkWithAFile(par_id3146120.10)

Dim iNumber As Integer
Dim iNumber As Integer(par_id3154319.11)

Dim sLine As String
Dim sLine As String(par_id3151117.12)

Dim aFile As String
Dim aFile As String(par_id3147426.13)

Dim sMsg as String
Dim sMsg as String(par_id3149667.36)

aFile = "c:\data.txt"
aFile = "c:\data.txt"(par_id3145800.14)

sMsg = ""
sMsg = ""(par_id3147396.15)

iNumber = Freefile
iNumber = Freefile(par_id3154490.16)

Open aFile For Output As #iNumber
Open aFile For Output As #iNumber(par_id3151074.17)

Print #iNumber, "First line of text"
Print #iNumber, "First line of text"(par_id3155416.18)

Print #iNumber, "Another line of text"
Print #iNumber, "Another line of text"(par_id3153416.19)

Close #iNumber
Close #iNumber(par_id3149401.20)

iNumber = Freefile
iNumber = Freefile(par_id3150330.24)

Open aFile For Input As #iNumber
Open aFile For Input As #iNumber(par_id3155067.25)

While not eof(#iNumber)
While not eof(#iNumber)(par_id3155443.26)

Line Input #iNumber, sLine
Line Input #iNumber, sLine(par_id3153714.27)

If sLine <>"" then
If sLine <>"" then(par_id3148408.28)

sMsg = sMsg & sLine & chr(13)
sMsg = sMsg & sLine & chr(13)(par_id3156385.29)

end if
end if(par_id3145147.31)

wend
Wend(par_id3153966.32)

Close #iNumber
Close #iNumber(par_id3155961.33)

Msgbox sMsg
Msgbox sMsg(par_id3149567.37)

End Sub
End Sub(par_id3146917.34)


< Prev / Next >